#include <QCoreApplication>
#include <QApplication>
#include <QDebug>
#include <iostream>
#include <QPushButton>
#include <QTimer>
#include <QLabel>
#include "qmywidget.h"

using std::cout;
using std::endl;

int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
//    qDebug() << "Hello World";
    QObject *obj = new QPushButton;
    cout << obj->metaObject()->className() << endl;

    QTimer *timer = new QTimer;
    cout << timer->inherits("QTimer") << endl;
    cout << timer->inherits("QObject") << endl;
    cout << timer->inherits("QAbstrctButton") << endl;

    QObject *obj2 = new QMyWidget;
    QWidget *widget = qobject_cast<QWidget *>(obj);
    QMyWidget *myWidget = qobject_cast<QMyWidget *>(obj);
    QLabel *label = qobject_cast<QLabel *>(obj);
    if (label == nullptr) {
        cout << "label is nullptr." << endl;
    } else {
        cout << "label is not nullptr" << endl;
    }

    return QCoreApplication::exec();
}
